<? include("/inc/header.html") {} ?>

	 <div class="col-lg-4">
		<div class="panel" style="height: 540px" overflow: auto;">
			<div > 
			<table class="table">
                   <tbody id="roles"></tbody>
             </table>
            </div>
		</div>
	</div>
<script type="text/javascript">
var roleid = window.parent.getRoleid();
	//查询角色
	$(function()  {
		queryRoles();
	});
	function queryRoles(){
			$.ajax({
			type : "post",
			data : {
			"id":roleid
			},
			url : "knowledgeEditDataQueryUser.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : function(data){
			//alert(JSON.stringify(data));
			var str = "";   
      		 $("#roles").html("");
       			for(var i=0;i<data.length;i++){
           		 str+="<tr><td>";
           		 	if(data[i].page == 1){
           		 		str+="<input type='checkbox' name='checkall' checked='true' value='"+data[i].id+"'/>";
           		 	}else{
           		 		str+="<input type='checkbox' name='checkall' value='"+data[i].id+"'/>";
           		 	}
                    str+= "<a>"+data[i].name+"</a>"                 
                    +"</td></tr>"                   
           		 }
           	$("#roles").append(str);
			}
		});
	}
	
	function save(){
		var value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		$.ajax({
			type : "post",
			data : {
				"roleId" : value,
				"id" : roleid
			},
			url : "knowledgeEditDataAddUser.do",
			dataType : "json",
			traditional : true,
			beforeSend : function(XMLHttpRequest) {},
			success : function(){
				 var index = parent.layer.getFrameIndex(window.name); 
           		 parent.layer.msg('添加或编辑成功');
           		  window.parent.queryUser();
            	 parent.layer.close(index); 
            	 
			},
		});
	}
	
</script>
